<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="./lib/themes/metro/easyui.css" />
    <link rel="stylesheet" href="./lib/themes/icon.css" />
</head>
<body>
    <div id="app" >
        <div data-bind="component:componentVm" ></div>
        <button data-bind="click:change">ctest/textbox切换</button>
    </div>
    <script src="./lib/jquery.min.js"></script>
    <script src="./lib/jquery.easyui.min.js"></script>
    <script src="./lib/locale/easyui-lang-zh_CN.js"></script>
    <script src="./lib/knockout-3.5.0.js" ></script>
    <script src="/koeasyui.js"></script>
    <script>
        koeasyui.use(window.ko);
        var componentVm={
            name: ko.observable('ctest'),
            params: {
               options:{ value: '同一数据源' }
            }
        }
        var rootVm={
            change:function(){
                componentVm.name() == 'ctest' ? componentVm.name('ko-textbox') : componentVm.name('ctest');
            }
        };
        ko.components.register('ctest',{
            template:'<div><ko-textbox params="options:{iconCls:\'icon-search\', value:text}" ></ko-textbox></div>',
            viewModel:function(params, compConfig){
                this.text = params && params.options && params.options.value;
                this.dispose = function(){
                    console.log('out dispose');
                }
                this.activate = function(){
                    console.log('activate');
                }
                this.afterPaint = function(){
                    console.log('afterPaint');
                    console.log('..................');
                }
                this.beforePaint = function(){
                    console.log('beforePaint');
                }
                this.beforeMount = function(){
                    console.log('挂载前')
                }
                this.afterMount = function(){
                    console.log('挂载后');
                }
            }
        });
        ko.applyBindings(rootVm, document.getElementById('app'));
    </script>
</body>
</html>